<!--  -->
<template>
  <div class="m-user">
    <template v-if="user">
      欢迎您，<span class="username">{{user}}</span>
      [<nuxt-link to='/exit'>退出</nuxt-link>]

    </template>
    <template v-else>
      <nuxt-link to='/login'>立即登录</nuxt-link>
      <nuxt-link to='/register'>注册</nuxt-link>
      <!-- zheli -->
    </template>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user: ""
    };
  },
  async mounted() {
    const {
      status,
      data: { user }
    } = await this.$axios.get("/users/getUser");
    if (status === 200) {
      this.user = user;
    }
  },
  components: {},

  computed: {},

  methods: {}
};
</script>
<style lang='scss' scoped>
.m-user {
  & > * {
    line-height: 40px;
  }
}
</style>
